package com.tanhua.server.controller;


import com.tanhua.model.vo.PageResult;
import com.tanhua.server.service.SmallVideosService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/smallVideos")
@Slf4j
public class SmallVideosController {


    @Autowired
    private SmallVideosService videosService;

    @PostMapping
    public ResponseEntity smallVideos(MultipartFile videoThumbnail, MultipartFile videoFile) throws IOException {
        log.info("文件封面:{}",videoThumbnail);
        log.info("文件内容:{}",videoFile);
      videosService.saveVidos(videoThumbnail,videoFile);
      return ResponseEntity.ok(null);
    }

    @GetMapping
    public  ResponseEntity queryVideoList(@RequestParam(defaultValue = "1")  Integer page,
                                          @RequestParam(defaultValue = "10") Integer pagesize){
        PageResult pr=videosService.findByVideos(page,pagesize);
        return ResponseEntity.ok(pr);
        }
}
